<style>
    .modal_sellcard{}
    .modal_sellcardmemberinfo div{line-height:24px;}
    .modal_sellcardpaytype{ font-size: 10px;}

    .modal_sellcardpaytype .layui-form-radio{ margin-right: 4px;padding-right: 0}
    .modal_sellcardpaytype .layui-form-radio .layui-icon{margin-right: 2px}

</style>
<div class="modal_sellcard" style="display:none">
    <div style="padding:15px">
        <div class="msc_info form-inline">
            <input class="form-control" type="text" id="msc_keyword" placeholder="输入卡号/姓名/电话" /> <button type="button" class="btn btn-default" onclick="funExtend_msc_searchmember()">搜索</button>
            <input type="hidden" id="msc_mid" value="0" />
            <span class="pull-right msc_memberinfo"></span>

        </div>
        <div class="msc_cardlist">
            <div class="row">
                <div class="col-md-4">
                    <table class="layui-table" lay-skin="line" id="mmc_membertable" lay-data="{height:400, page:false, id:'mmc_membertable'}" lay-filter="mmc_membertable">
                        <thead>
                        <tr>
                            <th lay-data="{field:'id', width:200}">已有项目</th>
                            <th lay-data="{field:'id1', width:80}">次数</th>
                        </tr>
                        </thead>
                        <tbody id="msc_haspro">
                        </tbody>
                    </table>
                </div>
                <div class="col-md-8">
                    <table id="mmc_protable" class="layui-table" lay-skin="line" lay-data="{height:400, page:false, id:'mmc_protable'}" lay-filter="mmc_protable">
                        <thead>
                        <tr>
                            <th lay-data="{field:'id', width:90}">卡名</th>
                            <th lay-data="{field:'id1', width:220}">项目</th>
                            <th lay-data="{field:'id2', width:90}">价格</th>
                            <th lay-data="{field:'id3', width:60}">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        {loop $timecardcategory $row}
                        <tr>
                            <td>{$row['title']}</td>
                            <td>{php $content=json_decode($row['content'],true);}
                                {loop $content $index $rew}
                                <span>{php echo $objary[$index]}：{$rew}</span>
                                {/loop}</td>
                            <td class="mmc_price" price="{$row['price']}">{$row['price']}</td>
                            <td><button class="btn btn-xs btn-warning" onclick="funExtend_selectPro({$row['id']})"><i class="fa fa-shopping-cart"></i></button></td>
                        </tr>
                        {/loop}
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="modal_sellcardpaybox" style="display:none">
    <form action="" class="layui-form" onsubmit="return false" style="padding:15px">
        <table class="layui-table" lay-skin="line">
            <tbody>
            <tr>
                <td colspan="2">9999999999999</td>
            </tr>
            <tr>
                <td>姓名</td>
                <td>电话</td>
            </tr>
            <tr>
                <td colspan="2">余额</td>
            </tr>
            </tbody>
        </table>
        <div class="modal_sellcardmemberinfo">
            <div class="row">
                <div class="col-md-7">
                    卡标题
                </div>
                <div class="col-md-2">
                    1
                </div>
                <div class="col-md-3">
                    9999.99
                </div>
            </div>
        </div>
        <div class="input-group" style="margin:10px 0">
            <span class="input-group-addon">费用</span>
            <input type="text" class="form-control" id="msc_fee"/>
            <span class="input-group-addon">元</span>
        </div>
        <div class="modal_sellcardpaytype">
            <input type="radio" name="msc_paytype"  lay-filter="msc_paytype" value="-1" title="赠送" checked/>
            <input type="radio" name="msc_paytype"  lay-filter="msc_paytype" value="2" title="现金" checked/>
            <input type="radio" name="msc_paytype"  lay-filter="msc_paytype" value="3" title="银行卡" />
            <input type="radio" name="msc_paytype"  lay-filter="msc_paytype" value="0" title="电子支付" />
            <input type="radio" name="msc_paytype"  lay-filter="msc_paytype" value="4" title="余额" />
        </div>
        <div style="margin-top:40px"><button class="btn btn-block btn-success btn-lg" type="button" onclick="funExtend_sellcardpay()">购买</button></div>
    </form>
</div>
<script language="javascript">

    function funExtend_sellcard(){
        layer.open({
            type: 1,
            title:"次卡销售",
            area:["760px","540px"],
            skin: 'layui-layer-rim',
            content:$(".modal_sellcard").show(),
            success: function(layero, index){
                $(".msc_memberinfo").empty();
                $("#msc_haspro").empty();
                layui.use('table', function() {
                    var table = layui.table;
                    table.render();
                });
            },
            end:function(){
                $(".modal_sellcard").hide();
                $("#msc_mid").val("");
            }
        });
    }
    function funExtend_msc_searchmember(){
        var keyword=$("#msc_keyword").val();
        if(!keyword){
            layer.msg("请输入关键字",{icon:2,time:1500});
            return;
        }
        var index2=layer.load(1, {shade: [0.1,'#fff']});
        $.post("{php echo $this->createMobileUrl('member',array('op'=>'searchmember'))}",{keyword:keyword},function(returnstr) {
            layer.close(index2);
            console.log(returnstr);
            var result = eval("(" + returnstr + ")");
            if (result.success) {
                var member=result.member;
                var list=result.list;
                var temp='<button type="button" class="btn btn-info">卡号：<span>'+(member.cardno ? member.cardno : member.wxcardno )+'</span></button> <button type="button" class="btn btn-info">'+(member.realname ? member.realname : member.mobile)+'</button> <button type="button" class="btn btn-info">余额：<span>'+member.cash2+'</span></button> ';
                $(".msc_memberinfo").html(temp);
                $("#msc_mid").val(member.id);
                $("#msc_haspro").empty();
                layui.use('table', function() {
                    var table = layui.table;
                    table.render();
                    table.render({
                        elem: '#mmc_membertable',
                        cols: [[
                            {field: 'title', title: '已有项目', width: 190}
                            ,{field: 'num', title: '次数', width: 80}
                        ]],
                        height:400,
                        page:false,
                        data:list,
                    });
                });
            }else{
                layer.msg(result.msg,{icon:2,time:1500});
                return;
            }
        });
    }

    function funExtend_selectPro(id){
//        var mid=parseInt($("#msc_mid").val());
//        if(!mid){
//            layer.msg("请先选择会员",{icon:2,time:1500});
//            return;
//        }
        layer.open({
            type: 1,
            title:"次卡销售",
            area:"390px",
            skin: 'layui-layer-rim',
            content:$(".modal_sellcardpaybox").show(),
            success: function(layero, index){
                layui.use('form', function() {
                    var form = layui.form;
                    form.render();
                });
            },
            end:function(){
                $(".modal_sellcardpaybox").hide();
            }
        });
    }
    layui.use(['layer','form'], function(){
        var layer = layui.layer
                ,form = layui.form;
    });

</script>